package com.itboye.ihomebank.activity.home;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;

import com.itboye.ihomebank.R;
import com.itboye.ihomebank.adapter.MyFaBuAdapter;
import com.itboye.ihomebank.base.BaseOtherActivity;
import com.itboye.ihomebank.bean.ResultEntity;
import com.itboye.ihomebank.constants.SPContants;
import com.itboye.ihomebank.custom.MyListView;
import com.itboye.ihomebank.presenter.HousePresenter;
import com.itboye.ihomebank.util.ByAlert;
import com.itboye.ihomebank.util.SPUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Observable;
import java.util.Observer;

import static com.itboye.ihomebank.activity.home.ActivityRenZheng.ActivityRenZheng_ResultOk;

/**
 * 我的发布
 * 
 */
public class ActivityMyFaBu extends BaseOtherActivity implements
		OnClickListener, Observer {
	View v_statusbar;
	private ImageView close_icon;// 返回图片
	private TextView add_shap_title_tv;// 标题

	MyListView fabu_listView;

	MyFaBuAdapter adapter;
	HousePresenter housePresenter;
	List<String> list;
	private String uid;

	private List<String> source() {

		list = new ArrayList<>();
		list.add("状态：待预订");
		list.add("青龙湾三期南区  3室1厅");
		list.add("青龙湾三区  三室一厅  朝南  172平");
		list.add("状态：待预订");
		list.add("2300元/月");
		list.add("下架房源");
		list.add("刷新置顶");
		list.add("付佣服务");
		list.add("选择租客");

		return list;
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.close_icon:
			finish();
			break;

		default:
			break;
		}

	}

	@Override
	protected int layout_id() {
		// TODO Auto-generated method stub
		return R.layout.activity_my_fa_bu;
	}

	@Override
	protected void onInitController() {
		// TODO Auto-generated method stub

	}

	@Override
	protected void onInit() {
		// TODO Auto-generated method stub
		setStatusBarHeight(v_statusbar);
		add_shap_title_tv.setText("我的发布");
		housePresenter = new HousePresenter(this);
		uid = SPUtils.get(this, null, SPContants.USER_ID, "") + "";
		housePresenter.getWoDeFaBu("11");
		adapter = new MyFaBuAdapter(this, source(), R.layout.item_wodefabu);

		fabu_listView = (MyListView) findViewById(R.id.fabu_listView);
		fabu_listView.setAdapter(adapter);
	}

	@Override
	protected void onReadIntent(Bundle bundle) {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(Observable observable, Object data) {
		// TODO Auto-generated method stub
		ResultEntity entity = handlerError(data);
		if (entity != null) {
			if (entity.getEventType() == HousePresenter.woDeFaBuList_success) {
				ByAlert.alert(entity.getData());
			} else if (entity.getEventType() == HousePresenter.woDeFaBuList_fail) {
				ByAlert.alert(entity.getData());
			}
		}
	}

//	@Override
//	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//		super.onActivityResult(requestCode, resultCode, data);
//
//        if (requestCode == MyFaBuAdapter_REQUEST&&resultCode== ActivityRenZheng_ResultOk){
//
//        	data.getIntExtra("position",0);
//		}
//	}
}
